package com.lqzs.businessmanager.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update
import com.lqzs.businessmanager.bean.MerChantInfo

@Dao
interface MerChantDao {

    @Query("SELECT * FROM merchant_table")
    suspend fun getAll(): MutableList<MerChantInfo>

    @Query("""SELECT * FROM merchant_table WHERE mc_userName = :userName AND mc_fraction = :fraction AND mc_chaseComments = :chaseComments AND mc_chaseComments_time = :chaseCommentsTime AND mc_reviewFollow = :reviewFollow AND mc_orderDetails = :orderDetails AND mc_upload = 0""")
    fun findMerChantInfo(
        userName: String?,
        fraction: String?,
        chaseComments: String?,
        orderDetails: String?,
        chaseCommentsTime: String?,
        reviewFollow: String?
    ): MutableList<MerChantInfo>?

    @Query("SELECT * FROM merchant_table WHERE mc_reviewId = :reviewId")
    suspend fun queryForId(reviewId:String): MerChantInfo?

    @Query("SELECT * FROM merchant_table WHERE mc_upload = 0 OR mc_upload=3")
    suspend fun queryNoUpload(): MutableList<MerChantInfo>

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertOrUpdate(merChantInfo: MerChantInfo)

    @Insert
    suspend fun insertAll(merChantInfo: MerChantInfo)

    @Delete
    suspend fun delete(merChantInfo: MerChantInfo)

    @Update
    suspend fun update(merChantInfo: MerChantInfo)
}